<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title> MIX Online's Gestalt: Write Ruby, Python and XAML in your HTML pages.</title>
    <link rel="icon" href="/favicon.gif" type="image/gif" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />
    <meta name="description" content="MIX Online is a community for web designers and developers who build and believe in the innovative web. We also have a sister conference called MIX. Simply, this is who we are." />
    <meta name="keywords" content="MIX Online, microsoft, gestalt, RIA, python, ruby, python, ironruby, ironpython, XAML, design, designer, web design, web designer, css, html, xhtml, css, javascript, ajax, silverlight, wpf, flash, web standards" />
    <link type="application/rss+xml" rel="alternate" title="Lab" href="/Lab/RSS" />
    <link type="application/rss+xml" rel="alternate" title="MIX Online" href="/RSS" />


	<!-- 
	=======================================================================
	REQUIRED STUFF
	Do not remove these links/scripts as they are required for the 
	skeleton of every lab site. 
	======================================================================= 
	-->

	<!-- Eric Meyer's CSS reset - Resets browser styles to defaults -->
	<link href="../../common/css/reset.css" rel="stylesheet" type="text/css" />

	<!-- This stylesheet contains the upsell bar & footer styles -->
	<link href="../../common/css/base.css" rel="stylesheet" type="text/css" />


	<!-- 
	=======================================================================
	OPTIONAL STUFF
	Common stuff like js libs, lightbox, etc. Use whatever you need and 
	throw the rest away
	=======================================================================
	-->

	<!-- 1Kb grid framework - 1kbgrid.com -->
	<link href="../../common/css/grid.css" rel="stylesheet" type="text/css" />
		
	<!-- JQuery minified - v1.3.2 -->
	<script src="../../common/js/jquery-1.3.2.min.js" type="text/javascript"></script>
	
	<!-- Gestalt Styles & Scripts-->
	<link rel="stylesheet" href="../css/gestalt.css" type="text/css" />
	<script src="../js/jquery.cycle.all.min.js" type="text/javascript"></script>
	<script src="../js/jquery.tooltip.min.js" type="text/javascript"></script>
	<script src="../js/gestalt_all.js" type="text/javascript"></script>	
	
</head>
<body id="faqs">
	
	<!-- 
	Begin WEBTRENDS (required) 
	This script is necessary for analytics for all evnet properties. Do not remove.
	-->
	<script src="/content/js/webtrends.1.js" type="text/javascript"></script>
	<script type="text/javascript">	    /*<![CDATA[*/var _tag = new WebTrends(); _tag.dcsGetId(function() { _tag.dcsCollect(); }); //]]></script>
	<noscript><div><img alt="DCSIMG" id="DCSIMG" width="1" height="1" src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcsuri=/nojavascript&amp;WT.js=No&amp;WT.tv=8.6.1"/></div></noscript>
	<!-- End WEBTRENDS -->
	
	<!--
	Begin UPSELL BAR (required)
	This is the markup for the upsell bar above the header of the page. You 
	have to retain this, but feel free to override the styles in your own
	stylesheet.
	-->	
	<div id="upsell">
		<a href="http://www.visitmix.com/labs/">
			<span>Like what you see? Check out other labs at the <span>MIX Online</span> Lab »</span>
		</a>
	</div>
	<!-- End UPSELL BAR -->
	
	<div id="header" class="grid_16 row">
		<h1 id="logo" class="column"><a href="/labs/gestalt1/">Gestalt (beta)</a></h1>
		<ul id="nav" class="column">
			<li><a href="/labs/gestalt1/">home</a></li>
			<li> | </li>
			<li><a href="/labs/gestalt1/getstarted/">getting started</a></li>
			<li> | </li>
			<li><a href="/labs/gestalt1/downloads/">downloads</a></li>
			<li> | </li>
			<li><a href="/labs/gestalt1/samples/">samples</a></li>
			<li> | </li>
			<li class="active"><a href="/labs/gestalt1/faqs/">faqs</a></li>
			
			<li> | </li><li><a href="/labs/gestalt1/widgets/">widgets</a><sup>New!</sup></li>
<li> | </li><li id="tweet_it"><a href="http://twitter.com/home/?status=RT+MIX+Online+releases+open-source+js+library+to+write+Ruby,+Python+and+XAML+in+web+pages+http://r.ch9.ms/gestalt+%23gestalt+%23microsoft" title=" ">tweet it!</a></li>
		</ul>
	</div>
	
	<div id="content" class="grid_16 row">
		
		<div id="question_list" class="grid_10 column">	
			<h2>Questions &amp; Known Issues</h2>		
			<p>We recommend you read through this list before you start using Gestalt. There are some known issues with this release, while there are others with how browsers handle different scenarios. Some of these answers may say you a few hours of hair-pulling debugging.</p>
			<h3>Known Issues</h3>
			<ol>
				<li><a href="" class="question">Locally run copies of a Gestalt application won't run.</a>
					<span><p>When a Gestalt application is run locally the Gestalt application will not instantiated. This is "by design"; the browser sandbox doesn't allow files that need to be served off a web server to be read off the local disk. The solution is to place your files on a web server and request the pages from there</li>	
					</span>
				</li>				
				<li><a href="" class="question">Why Don’t Relative Media and Image Paths Work in XAML?</a>
					<span><p>If you use relative image and media paths in your XAML (as in the example above), the images will be loaded relative to the location of the Gestalt XAP, and not relative to the page (unless the page and XAP are in the same folder).  There are three ways to resolve this:</p>
					<ol>
						<li>Use absolute paths.</li>
						<li>Use relative paths that are relative to the Gestalt XAP (see gestaltpath in gestalt.js).</li>
						<li>Move the Gestalt files to the same folder as your page.</li>
					</ol>	
					</span>
				</li>
			</ol>
			<h3>Questions</h3>
			<ol>
				<li><a href="" class="question">Why does my Ruby work and equivalent Python code fail?</a>
					<span><p>Indentation is significant in Python. Most likely your script is indented over within that page and that has the effect of changing the very meaning of your Python code. We highly recommend that when you’re writing a Python script, let it start at the first column and indent as necessary there on out. Problems are typically caused when you copy/paste Python code into the page.</p></span>
				</li>
				
				<li><a href="" class="question">Why is XAML inside a Script Tag?</a>
					<span><p>This has been changed from XML tag in Gestalt 0.6 to the Script tag in Gestalt 1.0. This has the follwoing two advantages:
					<ol>
					    <li>There are no breakages in any of the browsers</li>
					<li>Gestalt application's can be run in isolated scopes the "id" of the XAML script is the same as the "class" of the Ruby or Python script tag.</li>
					</ol>
					</span>
				</li>
								
				<li><a href="" class="question">How Do I Import Namespaces in Ruby and Python?</a>
					<span><p>If you want to import (for example) the System.Diagnostics namespace, the syntax in IronRuby is:</p>
					<p><pre>include System::Diagnostics</pre></p>
					<p>and the syntax in IronPython is:</p>
					<p><pre>from System.Diagnostics import *</pre></p>
					<p>By default, the following namespaces are available to your IronRuby code:</p>
					<p><pre>
include System::Windows::Controls
include System::Windows::Browser
include System::Windows::Media
include System::Windows
include System::Json</pre></p>
					<p>And the following namespaces are imported by default for IronPython:</p>
					<p><pre>
from System.Windows.Controls import * 
from System.Windows.Browser import *
from System.Windows.Media import *
from System.Windows import *
from System import EventHandler</pre></p>
		<p></p>
                    </span>
				</li>
				<li><a href="" class="question">How Can I Scope a Script to Run Only for One XAML Block?</a>
					<span><p>By default, each script applies to every XAML block on your page. If you want to constrain a certain script block to be visible to only one XAML block, you can scope it by setting the class attribute on the script tag.  For example, if you have a XAML block with id="blinking_mushroom", you can scope a python or ruby script like this:</p>
					<p><pre>&lt;script type="text/python" class="blinking_mushroom"&gt;</pre></p>
					<p></p>
					</span>
				</li>
				<li><a href="" class="question">How Many Copies of Gestalt Get Loaded?</a>
					<span><p>If you have zero or one XAML blocks on your page, Gestalt will be instantiated only once, no matter how many script blocks you have on the page.  This means that, if you are using Gestalt purely for DOM manipulation with Ruby or Python, you will have only one instance of Gestalt loaded, sharing global state, exactly as you would expect with JavaScript, regardless of how many script blocks you have.</p>
					    <p>If you have more than one distinct XAML block, Gestalt is instantiated exactly once per XAML block (again, regardless of the number of script blocks).  This is because the XAML blocks are loaded in Silverlight, which does not support multiple blocks per Silverlight instance.  Therefore, you probably don’t want to use more than 5 or 10 distinct XAML blocks on a page, just as you wouldn't want to use that many distinct Silverlight controls.</p>
					    <p>Of course, Gestalt is only downloaded once, regardless of how many XAML block are on the page</p>
					</span>
				</li>
				<li><a href="" class="question">How Can I Debug Ruby or Python in Visual Studio?</a>
					<span><p>Heres how you can do this for Ruby or Python:</p>
					    <ol>
					        <li>set: DLR.settings = { debug:true };
                            <li>define the .rb or .py file as external file like so:
                                <code>&lt;script class=”media” src=”audio.py” type=”text/python”&gt;&lt;/script&gt;</code>
                                or
                                <code>&lt;script class=”media” src=”audio.rb” type=”text/python”&gt;&lt;/script&gt;</code>

                            <li>Then attach the VS debugger to the instance of IE, FF or Chrome that you are running your app in

                            <li>Set a breakpoint in your .py or .rb file

                            <li>Refresh the browser

                            <li>You will see the debugger break on your breakpoint! Step through with F11
                        </ol>
					
					</span>
				</li>
				
				<li><a href="" class="question">How do I go about debugging a Gestalt application?</a>
					<span><p>Another convenient way to debug exceptions that are raised while you are developing your application is to add the System.Diagnostics namespace to your Python or Ruby code. In Python the syntax is:</p>
					<p><pre>from System.Diagnostic import *</pre></p>
                    <p>In Ruby the syntax is:</p>
                    <p><pre>include System::Diagnostic</pre></p>
                    <p>Then inline the following in your Python functions or classes. You can make a call to the Debug.Writeline() method which takes a string as a parameter:</p>
                    <p><pre>Debug.WriteLine("hello debug window")</pre> </p>
                    <p>or</p> 
                    <p><pre>Debug.WriteLine( <em>classInstance.aProperty</em>.ToString() ) 
# this will cast whatever object type the aProperty is to a string</pre></p>
                    <p>In Ruby, it's called similarly:</p>
                    <p><pre>Debug.WriteLine "hello debug window"</pre> </p>
                    <p>or</p>
                   	<p><pre>Debug.WriteLine <em>classInstance.aProperty</em>.ToString()</pre></p>
                    <p>It is also useful to know about the try/except statement in Python. Use it in this form inline in code. This writes the error message associated with the failed line of code to a debug window. DebugView is one tool that allows you to view debug messages.</p>
<p><pre>import sys
try:
   <em>some code that might fail</em>
except:
   Debug.WriteLine(sys.exc_info())</pre></p>
                    <p>In Ruby do the following:</p>
<p><pre>
begin
   <em>some code that might fail</em>
rescue => e
   Debug.WriteLine e.message</pre></p>
                    <p>You may find that background threads tend to swallow exceptions, such as a Storyboard_Completed event. You can add a Python try/except or a Ruby begin/rescue to any code in these and it will surface any errors that occur.</p>
                    <p>Note that to see a debug message appear you must be running both the <a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx">DebugView tool</a> and have www.visitmix.com added as a trusted site. Alternately you can run the files locally. You can use any other debugger tool that accepts debug messages as well.</p>
					<p>Take a look at a <a href="http://www.visitmix.com/labs/gestalt1/samples/debug/debug.python.html">Python debug sample</a>  and a <a href="http://www.visitmix.com/labs/gestalt1/samples/debug/debug.ruby.html">Ruby debug sample</a> and <a href="http://www.visitmix.com/labs/gestalt1/samples/debug/debug.zip">download the debug</a> samples pack.</p>
					<p></p>
					</span>
				</li>
			</ol>
		</div>
		<div id="ask_us" class="grid_6 column sidebar">
			<h2>Got a Question?</h2>
			<p>There's a good chance that the little issue that's driving you crazy is not your doing. We can probably save you some time if you drop us a line and ask us the nagging question. Heck, you may save everyone some time because we may just add it to list of known issues or frequently asked questions :)</p>
			<h3>Email us: <a href='&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#109;&#105;&#120;&#111;&#110;&#64;&#109;&#105;&#99;&#114;&#111;&#115;&#111;&#102;&#116;&#46;&#99;&#111;&#109;'>mixon (at) microsoft (dot) com</a></h3>
			<br />
			<br />
			<br />
			<br />
		</div>
	</div>
	
	
	
	<!--
	Begin FOOTER (required)
	This is the markup for the footer of the page. You have to retain this, but
	feel free to override the styles in your own stylesheet.
	-->
	<div id="footer">
		<ul>
			<li><a href="http://visitmix.com/Contact">Contact Us</a></li>
			<li> | </li>
			<li><a href="http://visitmix.com/CodeOfConduct">Code of Conduct</a></li>
			<li> | </li>
			<li><a href="http://visitmix.com/Terms">Terms of Use</a></li>
			<li> | </li>
			<li><a href="http://visitmix.com/Privacy">Privacy Statement</a></li>
		</ul>
		<p>A <a href="http://www.visitmix.com">MIX Online</a> Production. Copyright 2007-2009 Microsoft.</p>
	</div>
	<!-- End FOOTER (required) -->
	
	<!--
	Begin CRAZYEGG (required)
	-->
	<script type="text/javascript" src="http://cetrk.com/pages/scripts/0009/7517.js"> </script>
	<!-- End CRAZYEGG (required) -->	
	
</body>
</html>